package com.kedou.sdk.utils;

import android.util.Log;

/**
 * Created by Administrator on 2017/5/27 0027.
 */

public final class WL {

    private static final String WL_TAG = "51WANSY";

    private static volatile boolean writeDebugLogs = true;
    private static volatile boolean writeLogs = true;

    private WL() {
    }

    public static void writeDebugLogs(boolean writeDebugLogs) {
        WL.writeDebugLogs = writeDebugLogs;
    }

    public static void writeLogs(boolean writeLogs) {
        WL.writeLogs = writeLogs;
    }


    public static void d(String tag, String msg) {
        if (writeDebugLogs && writeLogs) {
            Log.d(WL_TAG, makeLogsMessage(tag, msg));
        }
    }

    public static void e(String tag, String msg) {
        if (writeDebugLogs && writeLogs) {
            Log.e(WL_TAG, makeLogsMessage(tag, msg));
        }
    }

    public static void i(String tag, String msg) {
        if (writeDebugLogs && writeLogs) {
            Log.i(WL_TAG, makeLogsMessage(tag, msg));
        }
    }

    public static void w(String tag, String msg) {
        if (writeDebugLogs && writeLogs) {
            Log.w(WL_TAG, makeLogsMessage(tag, msg));
        }
    }

    public static void v(String tag, String msg) {
        if (writeDebugLogs && writeLogs) {
            Log.v(WL_TAG, makeLogsMessage(tag, msg));
        }
    }


    private static String makeLogsMessage(String tag, String msg) {
        StringBuilder builder = new StringBuilder(" [");
        builder.append(tag);
        builder.append("]: ");
        builder.append(filterSensitiveString(msg));
        return builder.toString();
    }

    private static String filterSensitiveString(String msg) {
        //TODO If necessary, filter out sensitive string.
        return msg;
    }

}
